package com.zzyl.controller.manager;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.BedDto;
import com.zzyl.service.BedService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/bed")
@Api(tags = "床位管理")
public class BedController {


    @Autowired
    private BedService bedService;


    //TODO @ApiOperation("新增床位")


    @ApiOperation("新增床位")
    @PostMapping("/create")
    public ResponseResult createBed(@RequestBody BedDto beddto) {
        bedService.addBed(beddto);
        return ResponseResult.success();
    }



    //TODO @ApiOperation("根据ID查询床位")
    @ApiOperation("根据id查询床位")
    @GetMapping("/read/{id}")
    public ResponseResult getById(@PathVariable Long id) {
        return ResponseResult.success(bedService.getBedById(id));
    }




    //TODO @ApiOperation("更新床位")
    @ApiOperation("更新床位")
    @PutMapping("/update")
    public ResponseResult updateBed(@RequestBody BedDto beddto) {
        bedService.updateBed(beddto);
        return ResponseResult.success();
    }




    //TODO @ApiOperation("删除床位")
    @ApiOperation("删除床位")
    @DeleteMapping("delete/{id}")
    public ResponseResult deleteBed(@PathVariable Long id) {
        bedService.deleteBed(id);
        return ResponseResult.success();
    }
}
